package cn.baiweigang.uu.enums;

public enum TradeTypeEnum {

    ALL(0, "全部"),
    OPEN_BUY(1, "买入开多"),
    OPEN_SELL(2, "卖出开空"),
    CLOSE_BUY(3, "买入平空"),
    CLOSE_SELL(4, "卖出平多"),
    FORCE_CLOSE_SELL(5, "卖出强平"),
    FORCE_CLOSE_BUY(6, "买入强平"),
    DELIVERY_CLOSE_BUY(7, "交割平多"),
    DELIVERY_CLOSE_SELL(8, "交割平空"),
    ;

    private Integer code;
    private String desc;

    TradeTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static TradeTypeEnum byCode(Integer code) {
        TradeTypeEnum[] tradeStatusEnums = TradeTypeEnum.values();
        for (int i = 0; i < tradeStatusEnums.length; i++) {
            if (tradeStatusEnums[i].getCode() == code) {
                return tradeStatusEnums[i];
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
